import sympy as sym
import numpy as np
from fractions import Fraction
from sympy import sin,cos,Function
sym.init_printing()
#document:https://github.com/sympy/sympy


def mtimes(arg_a, arg_b, flag = True):
    if flag:
        return sym.simplify(np.dot(np.array(arg_a), np.array(arg_b)))
    else :
        return np.dot(np.array(arg_a), np.array(arg_b))
    
x = sym.symbols('x')
y = sym.symbols('y')
f = 2
A = [[x,sin(x)], [1, 2], [2, 3]]
B = [[x, x, x],[y, x**2, x]]
C = [x, 2*x**2, 3*x**3, 4*x**4]
D = [[1/x],[2/x**2], [3/x**3], [4/x**4]]


res = mtimes(A, B)
res1 = mtimes(C, D)
res2 = mtimes(f, A)
print(res)
print(res1)
print(res2)


